﻿<!--#include file="../Include/Config.asp"-->
<%
'----------------------------------------------------------
'页面功能：系统管理页面,问卷添加。
'最后修改时间：2007-11-24 14时36分
'作者：legal http://www.ilegal.cn
'备注：
'----------------------------------------------------------
dim action,Survey_name,Survey_author,Survey_description,Survey_dateOver,Survey_jdtz,Survey_ipRepeat
dim Survey_Password,Survey_ipLimitKind,Survey_ipList,Survey_isOpen,Survey_img
dim Survey_code,mo,da
action=request.QueryString("action")
select case action'当动作为添加问卷时
	case "addSurvey"
	Survey_name=request.Form("Survey_name")
	Survey_author=request.Form("Survey_author")
	Survey_img=session("imgurl")
	Survey_description=request.Form("Survey_description")
	Survey_dateOver=request.Form("Survey_dateOver")
	Survey_jdtz=request.Form("Survey_jdtz")
	Survey_ipRepeat=request.Form("Survey_ipRepeat")
	Survey_Password=request.Form("Survey_Password1")
	Survey_needUserInfo=request.Form("Survey_needUserInfo")
	Survey_annal=request.Form("Survey_annal")
	Survey_ipLimitKind=request.Form("Survey_ipLimitKind")
	Survey_isOpen=request.Form("Survey_isOpen")
	Survey_ipStart=request.Form("Survey_ipStart")
	Survey_ipEnd=request.Form("Survey_ipEnd")
	Survey_templet=request.Form("Survey_templet")
	if Survey_Password<>"" then'因为md5对空值也加密，所以先判断
	Survey_Password=md5(Survey_Password,16)
	end if
	if Survey_jdtz="" then'调节checkbox数据使之符合数据库要求
	Survey_jdtz="0"
	end if
	if Survey_ipRepeat="" then'调节checkbox数据使之符合数据库要求
	Survey_ipRepeat="0"
	end if
	if Survey_isOpen="" then'调节checkbox数据使之符合数据库要求
	Survey_isOpen="0"
	end if
	if Survey_needUserInfo="" then'调节checkbox数据使之符合数据库要求
	Survey_needUserInfo="0"
	end if
	if Survey_annal="" then'调节checkbox数据使之符合数据库要求
	Survey_annal="0"
	end if
	sql="select * from survey order by Survey_id desc"
	rs.open sql,conn,1,3
	mo=addZero(month(date),2)''产生问卷编号
	da=addZero(day(date),2)
	if rs.eof then
	code=addZero(0+1,4)
	else
	code=addZero(rs("Survey_id")+1,4)
	end if
	Survey_code=year(date)&mo&da&code
	rs.addnew
	rs("Survey_name")=Survey_name
	rs("Survey_description")=Survey_description
	rs("Survey_dateOver")=Survey_dateOver
	rs("Survey_jdtz")=Survey_jdtz  
	rs("Survey_author")=Survey_author
	rs("Survey_ipRepeat")=Survey_ipRepeat
	rs("Survey_password")=Survey_Password
	rs("Survey_needUserInfo")=Survey_needUserInfo
	rs("Survey_annal")=Survey_annal
	rs("Survey_ipLimitKind")=Survey_ipLimitKind
	rs("Survey_ipStart")=Survey_ipStart
	rs("Survey_ipEnd")=Survey_ipEnd
	rs("Survey_isOpen")=Survey_isOpen
	rs("Survey_img")=Survey_img
	rs("Survey_creatDate")=date
	rs("Survey_code")=Survey_code
	rs("Survey_templet")=Survey_templet
	rs.update
	rs.close
	session("imgurl")=""
	call ShowAlert("添加成功","SurveyAdmin.asp")
case "editSurvey"
	Survey_id=request.Form("Survey_id")
	Survey_name=request.Form("Survey_name")
	Survey_author=request.Form("Survey_author")
	Survey_img=request.Form("Survey_img")
	Survey_description=request.Form("Survey_description")
	Survey_jdtz=request.Form("Survey_jdtz")
	Survey_dateOver=request.Form("Survey_dateOver")
	Survey_ipRepeat=request.Form("Survey_ipRepeat")
	Survey_isOpen=request.Form("Survey_isOpen")
	Survey_isPassword=request.Form("Survey_isPassword")
	Survey_Password=request.Form("Survey_Password1")
	Survey_needUserInfo=request.Form("Survey_needUserInfo")
	Survey_annal=request.Form("Survey_annal")
	Survey_templet=request.Form("Survey_templet")
	if Survey_jdtz="" then'调节checkbox数据使之符合数据库要求
	Survey_jdtz="0"
	end if
	if Survey_ipRepeat="" then'调节checkbox数据使之符合数据库要求
	Survey_ipRepeat="0"
	end if
	if Survey_isOpen="" then'调节checkbox数据使之符合数据库要求
	Survey_isOpen="0"
	end if
	if Survey_needUserInfo="" then'调节checkbox数据使之符合数据库要求
	Survey_needUserInfo="0"
	end if
	if Survey_annal="" then'调节checkbox数据使之符合数据库要求
	Survey_annal="0"
	end if
	sql="select * from survey where Survey_id="&Survey_id
	rs.open sql,conn,1,3
	if rs("Survey_password")<>"" then
	    if Survey_isPassword<>"True" then
			rs("Survey_password")=""
		end if
	else
	    if Survey_isPassword<>"True" then
		else
			rs("Survey_password")=md5(Survey_Password,16)
		end if
	end if
	rs("Survey_name")=Survey_name
	rs("Survey_author")=Survey_author
	rs("Survey_img")=Survey_img
	rs("Survey_description")=Survey_description
	rs("Survey_dateOver")=Survey_dateOver
	rs("Survey_jdtz")=Survey_jdtz  
	rs("Survey_needUserInfo")=Survey_needUserInfo
	rs("Survey_annal")=Survey_annal
	rs("Survey_ipRepeat")=Survey_ipRepeat
	rs("Survey_isOpen")=Survey_isOpen
	rs("Survey_templet")=Survey_templet
	rs.update
	rs.close
	call ShowAlert("编辑成功","SurveyInfo.asp?Survey_id="&Survey_id)
end select  
%>
